
//import add from './admin-add.js';
/*import("./admin-add.js").then(m=>{
    console.debug(m);
});*/

//import del from './admin-del.js' ;
import  add from './admin-add.js';
let datagrid = document.querySelector("._datagrid");
let loadData = function () {
    fetch("admin-list.let").then((r) => r.json()).then((data) => {
        console.debug(data);
        datagrid.innerHTML = "";
        data.forEach((item) => {
            let tr = document.createElement("tr");
            tr.innerHTML = `
            <td>${item.adminId}</td>
            <td>${item.adminName}</td>
            <td>${item.adminPassword}</td>
            <td class="p-2"><div class="btn-group btn-group-sm">
                <button type="button" class="btn btn-primary" title="修改"><i class="fa fa-edit"></i></button>
                <button type="button" class="btn btn-danger _delete" title="删除"><i class="fa fa-remove"></i></button>
            </div></td>`;
            datagrid.appendChild(tr);


        });

    }).catch(e=>{
        console.error(e);
    });
}
loadData();
window.addEventListener("message",function (e){
    console.debug(e.data);
    if (e.data=="add:ok"){
        loadData();
    }

})
add();



